<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="scripts/jquery.min.js"></script>
    <title>Title</title>
    <script>
        function check(frm) {
            console.log("frm")
            console.log(typeof frm)
            //所有的标签（html、xml）在js世界都是一个个对象
            var username = frm.acname.value;
            var password = frm.passwd.value;
            if (username == "" || password == "") {
                alert("账户或密码不能为空")
                return false;
            }
            return true;
        }
    </script>
</head>
<body style="background-image: url('../../res/images/1.jpg');background-size: 100%"">
<div class="container" >

    <div class="row clearfix">
        <div class="col-md-12 column">
            <h3 id="ts" style="color:red"></h3>
            <form role="form" action="javascript:void(0)" onsubmit="return check(this)"
                  style="position: absolute;left: 40%;top: 40%;">
                <div class="form-group">
                    <label for="username">账户名</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;" type="text" class="form-control"
                           id="username" name="username"
                           placeholder="请输入用户名"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="password">密&nbsp;&nbsp;&nbsp;码</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;" type="password"
                           class="form-control" id="password" name="password"
                           placeholder="请输入密码"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="forgetpwd"></label>
                    <a href="forgetpass.html">忘记密码</a>

                </div>
                <div>
                    <button type="button" class="btn btn-default"
                            style="width: 90px;height: 25px; margin-top: 10px;margin-left:-20px;" onclick="login()">管理员登录
                    </button>
                    <button type="button" class="btn btn-default"
                            style="width: 100px;height: 25px; margin-top: 10px;margin-left: 10px;" onclick="clogin()">顾客登&nbsp;录
                    </button>
                    <button type="button" class="btn btn-default"
                            style="width: 100px;height: 25px; margin-top: 10px;margin-left: 10px;" onclick="window.location.href='zhuce.html'">注册
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>

<script>
    var httpreq=null;
    var ts = document.getElementById("ts")
    function login() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        if(username==""||password=="") {
            ts.innerHTML="用户名或密码不能为空"
            return
        }
        //ajax :google创新的一种应用
        //asynchronous javascript and xml【返回数据格式，刚推出时使用较多，现在几乎都使用json格式】
        $.ajax(
            {
                url:"admin/login",
                data:{username:username,password:password},
                success:function(result){
                    alert(result);
                    if(result.indexOf("success")!=-1){

                        window.location.href="frame/frame1/index.html";
                    }else{
                        $("#ts").html("无效的帐号或密码");
                    }
                }
            }
        );
    }
    function clogin() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        if(username==""||password=="") {
            ts.innerHTML="用户名或密码不能为空"
            return
        }
        $.ajax(
            {
                url:"customer/login",
                data:{username:username,password:password},
                success:function(result){
                    alert(result);
                    if(result.indexOf("success")!=-1){
                        window.location.href="frame/frame1/index.html";
                    }else{
                        $("#ts").html("无效的帐号或密码");
                    }
                }
            }
        );
    }

</script>
<!--<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>-->
<!--<script type="text/javascript">-->
<!--//初始化存放二维码的div-->
<!--var qrcode = new QRCode(document.getElementById("qrcode"), {-->
<!--width : 100,-->
<!--height : 100-->
<!--});-->
<!--//window.location.href获取到URL-->
<!--qrcode.makeCode("http://192.168.79.132:8080/barber/login.html");-->

<!--</script>-->
